package demo.controller;

import java.time.LocalDateTime;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import demo.event.MyEvent;

@RestController
public class EventController {
	
	
	@Autowired
    private ApplicationContext applicationContext;
	
	
	@RequestMapping("/publishEvent")
	public String publishEvent(){	
		String time = LocalDateTime.now().toString();
		applicationContext.publishEvent(new MyEvent(time,time));
		return "publishEvent done,"+time;
	}
	
	

	
}